package models;

import java.util.List;

import siena.Column;
import siena.Generator;
import siena.Id;
import siena.Model;
import siena.Query;
import siena.Table;

/**
 * 收入支出类型
 * @author 高恒
 *
 */
@Table("in_pay_type")
public class IncomeAndPaymentType extends Model {
	
	@Id(Generator.AUTO_INCREMENT)
	public Long id;
	
	@Column("name")
	public String name;
	
	@Column("direction")
	public FundsFlowDirection direction;
	
	public IncomeAndPaymentType(String name, FundsFlowDirection direction) {
		super();
		this.name = name;
		this.direction = direction;
	}

	public static List<IncomeAndPaymentType> getByDirection(FundsFlowDirection direction) {
		return all().filter("direction", direction).fetch();
	}

	public static Query<IncomeAndPaymentType> all() {
		return Model.all(IncomeAndPaymentType.class);
	}

	public static IncomeAndPaymentType get(Long id) {
		// TODO Auto-generated method stub
		return all().filter("id", id).get();
	}
	
}
